<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "goods".
 *
 * @property int $goods_id
 * @property string $goods_name
 * @property string $goods_img
 * @property string $goods_price
 */
class Goods extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'goods';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['goods_price'], 'number'],
            [['goods_name'], 'string', 'max' => 30],
            [['goods_img'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'goods_id' => 'Goods ID',
            'goods_name' => 'Goods Name',
            'goods_img' => 'Goods Img',
            'goods_price' => 'Goods Price',
        ];
    }
    public function selectAll(){
        //连库
        $connection = \Yii::$app->db;
        $command = $connection->createCommand('SELECT * FROM goods');
        $posts = $command->queryAll();
        return $posts;

    }
}
